﻿using Data;
using Infrastructure.States;
using Logic;
using UnityEngine;

namespace Level
{
    public class Exit : MonoBehaviour
    {
        private GameStateMachine _stateMachine;
        private GameSceneData _data;

        public void Construct(GameStateMachine stateMachine, GameSceneData data)
        {
            _stateMachine = stateMachine;
            _data = data;
        }

        private void OnTriggerEnter(Collider other)
        {
            if (!other.CompareTag(Constants.PlayerTag)) 
                return;
            _data.CurrentLevel++;
            _data.FieldSideSize += _data.FieldSideSizeIncrement;
            _data.CameraSize += _data.CameraSizeIncrement;
            _stateMachine.Enter<LoadLevelState, string>(Constants.Main);
        }
    }
}